<?php
namespace app\api\controller;

use think\Controller;

class Base extends Controller
{

    public function initialize()
    {
        //接受参数（非文件参数）
        $this->param = $this->request->param();
        //连接redis
        $this->redis = new \Redis();
        $this->redis->connect('127.0.0.1', 6379);
        //验证接口安全性（签名验证）
        // if(!isset($this->param['timestamp'])||!isset($this->param['sign'])){
        //     return apiReturn('签名参数未传');
        // }
        // if(!checkSign($this->param)){
        //     return apiReturn('签名错误');
        // }
        //验证接口唯一性
        // if(time()>(intval($this->param['timestamp'])+intval(Sign_Time))){
        //     return apiReturn('请求过期');
        // }
        //验证账号设备唯一性（token验证）
        $method = substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '/')+1);
        $noTokenMethod = array('regist','login','send_code');
        // if(!in_array($method,$noTokenMethod)){
        //     if(!isset($this->param['token'])||!isset($this->param['user_id'])){
        //         return apiReturn('Token参数未传');
        //     }
        //     $token = $this->param['token'];
        //     $user_id = $this->param['user_id'];
        //     if($token!=$this->redis->get('token_'.$user_id)){
        //         return apiReturn('当前账号已在其他设备上登录');
        //     }
        // }
        //调用模型
        $this->UserInfoModel = model('user_info'); //用户信息表

        //

    }
}
